<?php
/**
* This file is part of Webappkit, a packages system for PHP web apps
* @link http://webappkit.net
* @package webappkit
* @author J.Ducastel <nospam0@ducastel.name>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/

if (class_exists('waktool'))
    return;

/**
 * Generic tool builder for Kits
 */
class WakTool {
/*--------------------------------------------------------------------
STATIC METHODS
--------------------------------------------------------------------*/
    /**
     * factory pattern, use this method to build instances
     * all subclasses have to implement this method
     * because of PHP object model limitations
     * @static
     * @param string $kit_id parent kit id
     * @param array $cfg configuration data, will be merged with defaults
     * @return wakTool
     */
    function toolFactory($kit_id,$cfg) {
        return new WakTool($kit_id,$cfg);
    }

    /*function getDefaultCfg() {
        return self::$default_cfg;
    }*/
/*--------------------------------------------------------------------
INSTANCE METHODS
--------------------------------------------------------------------*/
    /**
     * get parent kit's id
     * @access public
     * @return string
     */
    function getKitId() {
        return $this->kit;
    }

    /**
     * get configuration data
     * @access public
     * @return array
     */
    function getCfg() {
        return $this->cfg;
    }
/*--------------------------------------------------------------------
CONSTRUCTOR
--------------------------------------------------------------------*/
    /**
    * php4 constructor
    * @access public
    */
    function wakTool($kit,$cfg=null) {
        $this->__construct($kit,$cfg);
    }/**/

    /**
    * "real" constructor.
    * will load conf
    * @access public
    * @param string $kit parent kit's id
    * @param string $cfg configuration data, will be merged with defaults
    */
    function __construct($kit,$cfg=array()) {
        $this->kit=$kit;
        // importing config
        if (is_array($cfg))
            $this->cfg=Webappkit::mergeArrays($this->default_cfg,$cfg);
        // doing some more initialization
        $this->_init();
    }/**/
/*--------------------------------------------------------------------
VARS / MEMBERS
--------------------------------------------------------------------*/
    /**
    * @var string parent kit id
    */
    var $kit;

    /**
    * @var string self unique name within kit
    */
    // var $name;

    /**
     * @var array defaults for configuration data
     */
    var $default_cfg=array();

    /**
     *@var array configuration data (defaults)
     */
    var $cfg=array();

    /**
     *
     */
    function _init() {
        return true;
    }
}